var http = require('http');
var fs = require('fs');
var url = require('url');

http.createServer(function (req,res) {
    var pname = url.parse(req.url).pathname;

    console.log('Request for' +pname+"received");

    fs.readFile(pname.substr(1),function (err,data) {
        if(err){
            console.log(err);
        }else {
            res.writeHead(404,{'Content-Type':'text/html'})

            res.write(data.toString());
        }
        res.end();
    })
}).listen(8080);
